import { PageMetaConfig } from './interface';

const baseUrl = '/sym/account';

export const apiUrl = {
  detail: `${baseUrl}/detail`, // 账号详情
  save: `${baseUrl}/create`, // 账号保存
  update: `${baseUrl}/update`, // 账号保存
  delete: `${baseUrl}/delete`, // 账号del
  list: `${baseUrl}/page`, // 账号del
  disable: `${baseUrl}/disable`, // 禁用
  enable: `${baseUrl}/enable`, // 启用
  reset: `${baseUrl}/resetPassword`,
  changePassword: `${baseUrl}/updatePassword`,
};

import { xhrPostJson } from '@/services';
import { DynamicObjectAny } from '@/typings';

interface saveParams extends DynamicObjectAny {
  pageCode: PageMetaConfig.CREATE;
}

export const accountSubmitSave = (params: saveParams) => {
  return xhrPostJson(apiUrl.save, params);
};

export const accountDetail = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.detail, params);
};

export const accountEdit = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.update, params);
};

export const accountDelete = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.delete, params);
};

export const accountRestPassword = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.reset, params);
};

export const accountEnable = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.enable, params);
};

export const accountDisabled = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.disable, params);
};

export const accountChangePassword = (params: DynamicObjectAny) => {
  return xhrPostJson(apiUrl.changePassword, params);
};
